import './assets/main.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import locale from 'element-plus/dist/locale/zh-cn.mjs' // 中文语言
import 'dayjs/locale/zh-cn'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import { createApp } from 'vue'
import '@/assets/index.scss' //
import App from './App.vue'
import router from './router'

import { setupStore } from './stores'

import './permisson'

import {
parseTime,
resetForm,
addDateRange,
handleTree,
selectDictLabel,
selectDictLabels,
formatTabData,
handleGo
} from '@/utils/utro'
import plugins from './plugins' // plugins
// 分页组件
import Pagination from '@/components/Pagination'
// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar'
// 表格组件
import HighTable from '@/components/HighTable'
// 字段渲染
import FieldRender from '@/components/FieldRender/FieldRender'
// 表单查询
import FormSearch from '@/components/FormSearch'
const app = createApp(App)

// 全局方法挂载
app.config.globalProperties.parseTime = parseTime
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.handleTree = handleTree
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels
app.config.globalProperties.formatTabData = formatTabData
app.config.globalProperties.$handleGo = handleGo

app.component('Pagination', Pagination)
app.component('RightToolbar', RightToolbar)
app.component('HighTable', HighTable)
app.component('FieldRender', FieldRender)
app.component('FormSearch', FormSearch)
app.use(plugins)
setupStore(app)
app.use(router)

app.use(ElementPlus, {
    locale: locale,
})

app.mount('#app')
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
